[P1] Fix wrong local save being deleted when creating a new run #4598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the changes the user will see?
No more accidentally erased save when creating a new run offline
One less trigger for save rollbacks when playing online
Why am I making these changes?
Losing runs or progress for no good reason is not great
The problem happens when creating a new run in a slot that has already a save file.
The game tries to delete the local save file in that slot before making the new one, but instead it deletes the save in the slot that was last played after a save & quit, otherwise it defaults to the first slot
Offline the run is fully lost, online there could be progress rollback if the run wasn't synced up with the server.
Note that this bug is part of why online players get rollbacks on their saves, but it's not the only reason. For example save & quitting or refreshing the page just after creating a new run seem to always result in all local saves getting erased, causing rollbacks for non synced runs.
This PR does not address those other issues so rollbacks will still happen
What are the changes from a developer perspective?
deleteSession
andtryClearSession
now use the providedslotId
parameter instead ofscene.sessionSlotId
Note that for
tryClearSession
it does not change anything since it's only called after a run is finished (either lost or won), so the slotId andscene.sessionSlotId
are the same in this case.Which is also why my examples are all about creating new games
Screenshots/Videos
Before: offline - slot 1 getting deleted when creating a run in slot 3
before-offline.mp4
After: offline - no deleted save after creating a new run
_after_offline.mp4
Before: online - slot 1 getting rolled back when creating a run in slot 3
before_online.mp4
After: online - no rollback for slot 1 after creating a new run in slot 2
after_online.mp4
How to test the changes?
Online:
Checklist
beta
as my base branchnpm run test
)